class PascalsTriangleGenerator {

    int[][] generateTriangle(final int i) {
        if (i < 0) {
            throw new IllegalArgumentException();
        }

        if (i < 1) {
            return new int[][]{};
        }

        int[][] result = new int[i][];

        for (int j = 0; j < i; j++) {
            result[j] = new int[j + 1];
            result[j][0] = 1;
            result[j][result[j].length - 1] = 1;
            for (int k = 1; k < result[j].length - 1; k++) {
                result[j][k] = result[j - 1][k] + result[j - 1][k - 1];
            }
        }

        return result;
    }
}